/**
 * projectName: mbzwb-parent
 * fileName: AssessController.java
 * packageName: com.palmdoctor.mb.server.assess.controller
 * date: 2021-08-09 14:38
 * copyright(c) 2021 http://www.hydee.cn/ Inc. All rights reserved.
 */
package com.zny.sescore.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zny.sescore.service.AssessModelService;
import com.zny.sescore.controller.CurdController;
import com.zny.sescore.model.ApiResult;
import com.zny.sescore.model.AssessModel;
import com.zny.sescore.model.CodeName;
import com.zny.sescore.model.PageWrap;
import com.zny.sescore.model.vo.AssessModelListVO;
import com.zny.sescore.model.vo.AssessModelVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version: V1.0
 * @author: zhangnayi
 * @className: AssessController
 * @packageName: com.palmdoctor.mb.server.assess.controller
 * @description: 评估模型接口
 * @data: 2021-08-09 14:38
 **/
@Api(tags = "评估模型接口")
@Slf4j
@RestController
@RequestMapping("/assess/model")
public class AssessModelController extends CurdController<AssessModelService, AssessModel> {

    @PostMapping("/page2")
    @ApiOperation("查询分页")
    public ApiResult<IPage<AssessModelListVO>> getModelPage(@RequestBody PageWrap<AssessModel> pageWrap) {
        return ApiResult.success(service.getModelPage(pageWrap.getPage(), new QueryWrapper<>(pageWrap.getModel())));
    }


    @ApiOperation("查看模板详情")
    @GetMapping("/detail")
    public ApiResult<AssessModelVO> getAssessModel(@RequestParam int modelId) {
        return ApiResult.success(service.getAssessModelVO(modelId));
    }

    @ApiOperation("保存模板详情")
    @PostMapping("/save_model")
    public ApiResult<Boolean> saveAssessModel(@RequestBody AssessModelVO model) {
        return ApiResult.success(service.saveAssessModel(model));
    }

    @ApiOperation("查看模板详情")
    @GetMapping("/source_category1")
    public ApiResult<List<CodeName>> getSourceCategory1(@RequestParam String itemSource) {
        return ApiResult.success(service.getSourceCategory1(itemSource));
    }

    @ApiOperation("查看模板详情")
    @GetMapping("/source_category2")
    public ApiResult<List<CodeName>> getSourceCategory2(@RequestParam String itemSource, @RequestParam String parentCode) {
        return ApiResult.success(service.getSourceCategory2(itemSource, parentCode));
    }
}